#!/usr/bin/env bash

export TGT_DIR=/usr/local/src/modern-linux-utils/

# less as pager, perl for fzf, git for delta, curl for curlie
# vim and nano as editor
export DEPS="bash bash-completion wget tar gzip unzip less perl git curl vim nano"

set -eux

build() {
	local IMAGE_TAG=$1
	local DOCKERFILE=$2
	local BASE_IMAGE_TAG=$3
	export BASE_IMAGE_TAG
	docker pull $BASE_IMAGE_TAG || :
	docker build -t $IMAGE_TAG -f $DOCKERFILE \
		--build-arg BASE_IMAGE_TAG \
		--build-arg TGT_DIR --build-arg DEPS .
}

build_push() {
	local IMAGE_TAG=$1
	local DOCKERFILE=$2
	local BASE_IMAGE_TAG=$3
	build $IMAGE_TAG $DOCKERFILE $BASE_IMAGE_TAG
	docker push $IMAGE_TAG
}

#build      zorxliu/modern-linux-utils:kylinserver-10sp1  yum.Dockerfile kylin-server-10-sp1-x86:b20.05.18.p01
build_push zorxliu/modern-linux-utils:openeuler-20.03sp2 yum.Dockerfile zorxliu/openeuler-20.03-lts-sp2
build_push zorxliu/modern-linux-utils:centos-7           yum.Dockerfile centos:7
build_push zorxliu/modern-linux-utils:ubuntu-20.04       apt.Dockerfile ubuntu:20.04
build_push zorxliu/modern-linux-utils:alpine-3           apk.Dockerfile alpine:3
